package com.chris.libs.devtools.x.v1.utils;

import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * create by Chris Chan
 * create on 2019/7/9 22:19
 * use for :屏幕工具类
 */
public class ScreenUtil extends UtilsManager {
    /**
     * 获取屏幕高度 像素
     *
     * @return
     */
    public static int getWidth() {
        return getDisplayMetrics().widthPixels;
    }

    /**
     * 获取屏幕宽度 像素
     *
     * @return
     */
    public static int getHeight() {
        return getDisplayMetrics().heightPixels;
    }

    /**
     * 获取状态栏高度 像素
     *
     * @return
     */
    public static int getStatueBarHeight() {
        int identifier = mContext.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (identifier > 0) {
            return mContext.getResources().getDimensionPixelSize(identifier);
        }
        return 0;
    }

    public static DisplayMetrics getDisplayMetrics() {
        WindowManager windowManager = (WindowManager) mContext.getSystemService(mContext.WINDOW_SERVICE);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        windowManager.getDefaultDisplay().getMetrics(displayMetrics);
        return displayMetrics;
    }

}
